<?php
	if($_POST['submit']!=true) echo '';
	else{
	$comment = trim(addslashes(htmlspecialchars($_POST['descr'])));
	$who_added = $_SESSION['username'];
	$date = time();
	$title = $_GET['id'];
	
	if(!empty($comment)){
	   if(strlen($comment) < 3){
	      echo '<p class="error">Кратът коментар!</p>';
	   } else {
	      $insert_into_comments = mysql_query('INSERT INTO com_t(who_added, comment, date, title_t) 
		  VALUES("'.$who_added.'", "'.$comment.'", '.$date.','.$title.')');
		  echo '<p class="success">Успешен запис!</p>';
		  ?>
		  <meta http-equiv="refresh" content="0;url=<?php echo 'see_t.php?id='.$_GET['id'].'';?>">
		  <?php
	   }
	} else {
	   echo '<p class="error">Всички полета са задължителни!</p>';
	}
	}
?>